<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<#include "/common/resources.ftl"/>
<script type="text/javascript">
	$(function(){
	    $("#closeOrder").window('close')
		window.m_datagrid = $('#m_datagrid').datagrid({
			url:'${ctx}/qfbao/loanorder/list',
			onLoadSuccess:yixun.closeProgress,
			onBeforeLoad:yixun.progress,
			queryParams:$('#load_list_search').serializeObject(),
			loadMsg:null,
			singleSelect:true,
			fitColumns:true,
			rownumbers:true,
			pagination:true,
			border:'false',
			toolbar:'#m_toolbar'
		});
	
		//按条件查询用户
		window.searchData = function () {
			m_datagrid.datagrid('load',$('#load_list_search').serializeObject());
		}
		
		//删除
		window.openCloseOrder = function(rowId){
		    $("#zzdk_remark").val("");
		    $("#optId").val(rowId);
			$("#closeOrder").window('open');
		}
		
		//删除
		window.saveCloseOrder = function(){
		    var zzdkRemark=$("#zzdk_remark").val()
		    if(zzdkRemark==""){
		       $.messager.alert("提示","终止备注必填！");
		       return;
		    }
		   	var url="${ctx}/qfbao/loanorder/stopOrder";
			$.ajax({
				 url:url,
				 type: "POST",
				 data:{optId:$("#optId").val(),zzdkRemark:zzdkRemark},
				 dataType:'JSON',
				 success:function(rs){
				 	if(rs.isSuccess=="0"){
				 		$("#closeOrder").window('close');
				 		m_datagrid.datagrid('reload');
				 	}else{
				 		$.messager.alert("错误信息",rs.errorMsg);
				 	}
				 },
				
			});
		}
	});
	mShowButton = function (value,row,index){
		var btns = [];
		//未签约、正常贷款订单
		if(row.signStatus=="1" && row.isWorking=="1"){
		  btns.push('<button class="green_btn" onclick="javascript:openCloseOrder(\''+value+'\');">关闭报备</button>');
		}
		btns.push('<button class="green_btn" onclick="javascript:window.location.href=\'view?id='+value+'\';void(0);">查看</button>');
		return btns.join('');
	}
	
	showStatusName=function(value,row,index){
	    var statusName="";
	    if(row.isWorking=="0"){
	       statusName="已取消"; 
	    }else{
	       if(row.checkStatus=="0" && row.signStatus=="1" && row.loanStatus=="0"){
	           statusName="报备未确认"; 
	       }else if(row.checkStatus=="1" && row.signStatus=="1" && row.loanStatus=="0"){
	           statusName="报备已确认"; 
	       }else if(row.checkStatus=="2" && row.signStatus=="1" && row.loanStatus=="0"){
	           statusName="报备无效"; 
	       }else if(row.checkStatus=="1" && row.signStatus=="2" && row.loanStatus=="0"){
	           statusName="已签约"; 
	       }else if(row.checkStatus=="1" && row.signStatus=="2" && row.loanStatus=="1"){
	           statusName="已放款"; 
	       }
	    } 
	    return statusName;
	}
</script>
</head>
<body style="background-color:white;">

<div id="m_toolbar" class="datagrid-toolbar" style="overflow: hidden;height: auto;margin: 15px 0px;background-color: white;border-bottom: none;" border="false">
  <form id="load_list_search" onsubmit="return false;">
  <div class="fm_sty" style="margin: 20px 0px 0px;">
   	<div class="ipt_line">
	<span class="ipt_title">手机号</span>
		<input type="text" name="phone" class="ipt_226" />
	</div>
	<div class="ipt_line">
	<span class="ipt_title">状态</span>
	    <select class="easyui-combobox" style="height:39px;width:263px;" name="allStatus">
	       <option value="">全部</option>
	       <option value="0,1,0">报备未确认</option>
	       <option value="2,1,0">报备无效</option>
	       <option value="1,1,0">报备已确认</option>
	       <option value="1,2,0">已签约</option>
	       <option value="1,2,1">已放款</option>
	       <option value="0">已取消</option>
	    </select>
	</div>

	<div class="ipt_line_long">
        <button class="red_100" onclick="searchData()">查询</button>
	</div>    
	
	<input type="hidden" value="${partnerId!''}" name="partnerId"/>
  </div>
  </form>
</div>

<!-- 查找结果 -->
<table style="margin:0px 20px;" id="m_datagrid">
	<thead>
		<tr>
			<th field="orderCode"  height="40" >订单号</th>
			<th field="applicant"  height="40" >姓名</th>
			<th field="phone"  height="40" >手机号</th>
			<th field="applyAmount"  height="40" >意向金额</th>
			<th field="mechanismName"  height="40" >分配商户</th>
			<th data-options="field:'checkStatusName',formatter:showStatusName,align:'center'"   height="40" >状态</th>
			<th field="applyDate"  height="40" >申请时间</th>
			<th data-options="field:'id',formatter:mShowButton,align:'center'" width="150">操作</th>
		</tr>
	</thead>
</table>

<div id="closeOrder" class="easyui-dialog" title="终止贷款订单" style="width:400px;height:220px;padding:10px 20px;"   data-options="iconCls:'icon-save',resizable:true,modal:true" >   
        	<div class="easyui-layout" fit="true">
        	    <input type="hidden" id="optId"/>
				<div region="center" border="false">
						<div class="fitem">
							<label>终止备注:</label>
							<textarea style="width:200px;height:100px;" id="zzdk_remark" required="true"></textarea>
						</div>
	   			</div>
	   			<div region="south" border="false" style="text-align:right;height:30px;line-height:30px;">
			      <a href="#" onclick="saveCloseOrder()" class="easyui-linkbutton" iconCls="icon-ok" plain="true">确定</a>
			      <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" plain="true" onclick="javascript:$('#closeOrder').window('close')">取消</a>
		        </div>
   			</div>
</div>

</body>
</html>
